<title>伪装客户端</title>
<meta charset="UTF-8"/>
<iframe src="index.html"  style="position: absolute;right:0;top:1%;min-height: 300px;border-width: 0px">
</iframe>
<h1>2.浑水摸鱼--伪装客户端</h1>
<p>
    对与一些使用js加载页面，可以调用go-chromedp-client，使用浏览器伪装正常用户加载页面，再处理返回结果
</p>
<h1>
  示例
</h1>
<xmp  style="background:#f0f0f0;white-space: pre;text-align: left" >
$finalNo="xxxx";
$url = 'https://tracking.expressone.hu/?plc_number='.$finalNo;
        $header = array(
            "Accept-Language: en-US",
            //"User-Agent: UPS/15 CFNetwork/1240.0.2 Darwin/20.6.3",
            'Accept-Encoding: gzip, deflate',
        );
   // echo $url;

        $data = '';
        //"www.google.com","www.recaptcha.net"
        $op=[
            "timeout"=>120 , //超时时间
            "selector"=>"body",
            "debug"=>0,
        ];
        $op['js']=[];

        $op['js'][]=<<<JS
        setInterval(()=>{
            if ($("#form-tracking")) {
                    $("#form-tracking").submit()
            }
        },5000)

JS;
        $op['js'][] ="WaitVisible:.history";
        $op['js'][] =<<<JS
            window.jsresult = document.getElementsByClassName("history")[0].outerHTML;
            window.document.body.innerHTML ='<div id="js_result" >'+window.jsresult+'</div>';
JS;

    //返回的抓取结果
        $content = HttpClient::RpcChromedpGet($url,$header,$op,$ip,$port);
        $contents = json_decode($content,true);
</xmp>
